package com.common.link.controller;

import com.common.link.model.RemoteOfficeVO;
import com.common.link.service.RemoteUserService;
import com.common.link.model.RemoteUserVO;
import com.common.model.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 描述：
 *
 * @author xianggj
 * @Date 2022/2/18 11:31
 **/
@Slf4j
@RestController
@RequestMapping("/user")
@Api(tags = "人员信息")
public class UserController {

    @Autowired
    private RemoteUserService remoteUserService;

    /**
     * 查询标注用户列表
     */
    @ApiOperation(value = "查询用户部门树")
    @GetMapping("/officeTree")
    public Result officeTree() {
        List<RemoteOfficeVO> officeList = remoteUserService.getOfficeList();
        return Result.succeed(officeList, "查询成功");
    }

    /**
     * 查询标注用户部门列表
     */
    @ApiOperation(value = "查询用户列表")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "部门id,多个逗号分隔，不传就是查询全部", name = "dids", required = false),
            @ApiImplicitParam(value = "用户名和部门名称模糊查询", name = "searchKey", required = false)
    })
    @GetMapping("/userList")
    public Result userList(@RequestParam(value = "dids", required = false) String dids,
                           @RequestParam(value = "searchKey", required = false) String searchKey) {

        List<RemoteUserVO> userList = remoteUserService.getUserList(dids, searchKey);
        return Result.succeed(userList, "查询成功");
    }

}
